package logic

import (
	"context"
	"wechat/models/mysql"

	"wechat/wechatrpc/internal/svc"
	"wechat/wechatrpc/wechatrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type WeAddLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewWeAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *WeAddLogic {
	return &WeAddLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 添加
func (l *WeAddLogic) WeAdd(in *wechatrpc.WeAddRequest) (*wechatrpc.WeAddResponse, error) {
	// todo: add your logic here and delete this line

	chat := mysql.WeChat{
		Image:        in.Image,
		NickName:     in.NickName,
		WeiXinNumber: in.WeiXinNumber,
		Address:      in.Address,
	}

	mysql.DB.Debug().Create(&chat)

	return &wechatrpc.WeAddResponse{
		Id: int64(chat.ID),
	}, nil
}
